package com.example.juc;

public class SyncTest {

    Object object=new Object();

    public static void main(String[] args) {

    }

    /**
     * 锁SyncTest。class对象
     */
    public static synchronized void m1(){
        System.out.println("测试静态方法synchronized");
    }

    /**
     * 锁SyncTest对象
     */
    public synchronized void m2(){
        System.out.println("测试对象方法synchronized");
    }

    /**
     * 锁synchronized代码块对象
     */
    public void m3(){
        synchronized (object) {
            System.out.println("测试代码块方法synchronized");
        }
    }

}
